package com.yytek.am.controller;

import java.util.List;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yytek.common.log.annotation.Log;
import com.yytek.common.log.enums.BusinessType;
import com.yytek.common.security.annotation.RequiresPermissions;
import com.yytek.am.domain.FmDefRlobject;
import com.yytek.am.service.IFmDefRlobjectService;
import com.yytek.common.core.web.controller.BaseController;
import com.yytek.common.core.web.domain.AjaxResult;
import com.yytek.common.core.utils.poi.ExcelUtil;
import com.yytek.common.core.web.page.TableDataInfo;

/**
 * 告警定义关联设备Controller
 * 
 * @author yytek-iot
 * @date 2022-10-10
 */
@Api(value = "告警定义关联设备控制器", tags = {"告警定义关联设备管理"})
@RestController
@RequestMapping("/defrlobject")
public class FmDefRlobjectController extends BaseController
{
    @Autowired
    private IFmDefRlobjectService fmDefRlobjectService;
    /**
     * 查询全部告警定义关联设备列表
     */
    @ApiOperation("查询全部告警定义关联设备列表")
    @RequiresPermissions("am:defrlobject:list")
    @GetMapping("/allList")
    public AjaxResult allList(FmDefRlobject fmDefRlobject)
    {
        List<FmDefRlobject> list = fmDefRlobjectService.selectFmDefRlobjectList(fmDefRlobject);
        return AjaxResult.success(list);
    }


    /**
     * 分页查询告警定义关联设备列表
     */
    @ApiOperation("查询告警定义关联设备列表")
    @RequiresPermissions("am:defrlobject:list")
    @GetMapping("/list")
    public TableDataInfo list(FmDefRlobject fmDefRlobject)
    {
        startPage();
        List<FmDefRlobject> list = fmDefRlobjectService.selectFmDefRlobjectList(fmDefRlobject);
        return getDataTable(list);
    }

    /**
     * 导出告警定义关联设备列表
     */
    @ApiOperation("导出告警定义关联设备列表")
    @RequiresPermissions("am:defrlobject:export")
    @Log(title = "告警定义关联设备", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FmDefRlobject fmDefRlobject)
    {
        List<FmDefRlobject> list = fmDefRlobjectService.selectFmDefRlobjectList(fmDefRlobject);
        ExcelUtil<FmDefRlobject> util = new ExcelUtil<FmDefRlobject>(FmDefRlobject.class);
        util.exportExcel(response, list, "告警定义关联设备数据");
    }

    /**
     * 获取告警定义关联设备详细信息
     */
    @ApiOperation("获取告警定义关联设备详细信息")
    @RequiresPermissions("am:defrlobject:query")
    @GetMapping(value = "/{alarmDefineId}")
    public AjaxResult getInfo(@PathVariable("alarmDefineId") Long alarmDefineId)
    {
        return AjaxResult.success(fmDefRlobjectService.selectFmDefRlobjectByAlarmDefineId(alarmDefineId));
    }

    /**
     * 批量新增告警定义关联设备
     */
    @ApiOperation("批量新增告警定义关联设备")
    @Log(title = "批量新增告警定义关联设备", businessType = BusinessType.INSERT)
    @PostMapping(value = "/addList")
    public AjaxResult addList(@RequestBody List<FmDefRlobject> fmDefRlobjectList)
    {
        return toAjax(fmDefRlobjectService.insertFmDefRlobjectList(fmDefRlobjectList));
    }

    /**
     * 新增告警定义关联设备
     */
    @ApiOperation("新增告警定义关联设备")
    @RequiresPermissions("am:defrlobject:add")
    @Log(title = "告警定义关联设备", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FmDefRlobject fmDefRlobject)
    {
        return toAjax(fmDefRlobjectService.insertFmDefRlobject(fmDefRlobject));
    }

    /**
     * 修改告警定义关联设备
     */
    @ApiOperation("修改告警定义关联设备")
    @RequiresPermissions("am:defrlobject:edit")
    @Log(title = "告警定义关联设备", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FmDefRlobject fmDefRlobject)
    {
        return toAjax(fmDefRlobjectService.updateFmDefRlobject(fmDefRlobject));
    }

    /**
     * 删除告警定义关联设备
     */
    @ApiOperation("删除告警定义关联设备")
    @RequiresPermissions("am:defrlobject:remove")
    @Log(title = "告警定义关联设备", businessType = BusinessType.DELETE)
	@DeleteMapping
    public AjaxResult remove(@RequestBody FmDefRlobject fmDefRlobject)
    {
        return toAjax(fmDefRlobjectService.deleteFmDefRlobject(fmDefRlobject));
    }
}
